﻿using System;
using System.Data;
using System.Text;
using System.Data.SqlClient;
using ZWL.DBUtility;//请先添加引用
namespace ZWL.BLL
{
	/// <summary>
	/// 类ERPXMLB。
	/// </summary>
	[Serializable]
	public partial class ERPXMLB
	{
		public ERPXMLB()
		{}
		#region Model
		private int _id;
		private string _project_id;
		private string _project_name;
		private int? _workflowid;
		private string _workflowname;
		private int? _formid;
		private string _formname;
		private string _jiedianserils;
		private string _jiedianname;
		private string _dangqianuser;
		private string _zhuanrujdserils;
		private int? _sfkbl;
		private int? _yxbs;
		private string _chuangjianren;
		private DateTime? _chuangjiansj;
		private DateTime? _banlisj;
		/// <summary>
		/// 
		/// </summary>
		public int ID
		{
			set{ _id=value;}
			get{return _id;}
		}
		/// <summary>
		/// 
		/// </summary>
		public string PROJECT_ID
		{
			set{ _project_id=value;}
			get{return _project_id;}
		}
		/// <summary>
		/// 
		/// </summary>
		public string PROJECT_NAME
		{
			set{ _project_name=value;}
			get{return _project_name;}
		}
		/// <summary>
		/// 
		/// </summary>
		public int? WorkFlowID
		{
			set{ _workflowid=value;}
			get{return _workflowid;}
		}
		/// <summary>
		/// 
		/// </summary>
		public string WorkFlowName
		{
			set{ _workflowname=value;}
			get{return _workflowname;}
		}
		/// <summary>
		/// 
		/// </summary>
		public int? FormID
		{
			set{ _formid=value;}
			get{return _formid;}
		}
		/// <summary>
		/// 
		/// </summary>
		public string FormName
		{
			set{ _formname=value;}
			get{return _formname;}
		}
		/// <summary>
		/// 
		/// </summary>
		public string JieDianSerils
		{
			set{ _jiedianserils=value;}
			get{return _jiedianserils;}
		}
		/// <summary>
		/// 
		/// </summary>
		public string JieDianName
		{
			set{ _jiedianname=value;}
			get{return _jiedianname;}
		}
		/// <summary>
		/// 
		/// </summary>
		public string DangQianUser
		{
			set{ _dangqianuser=value;}
			get{return _dangqianuser;}
		}
		/// <summary>
		/// 
		/// </summary>
		public string ZhuanRuJDSerils
		{
			set{ _zhuanrujdserils=value;}
			get{return _zhuanrujdserils;}
		}
		/// <summary>
		/// 
		/// </summary>
		public int? SFKBL
		{
			set{ _sfkbl=value;}
			get{return _sfkbl;}
		}
		/// <summary>
		/// 
		/// </summary>
		public int? YXBS
		{
			set{ _yxbs=value;}
			get{return _yxbs;}
		}
		/// <summary>
		/// 
		/// </summary>
		public string ChuangJianRen
		{
			set{ _chuangjianren=value;}
			get{return _chuangjianren;}
		}
		/// <summary>
		/// 
		/// </summary>
		public DateTime? ChuangJianSJ
		{
			set{ _chuangjiansj=value;}
			get{return _chuangjiansj;}
		}
		/// <summary>
		/// 
		/// </summary>
		public DateTime? BanLiSJ
		{
			set{ _banlisj=value;}
			get{return _banlisj;}
		}
		#endregion Model


		#region  Method

		/// <summary>
		/// 得到一个对象实体
		/// </summary>
		public ERPXMLB(int ID)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("select ID,PROJECT_ID,PROJECT_NAME,WorkFlowID,WorkFlowName,FormID,FormName,JieDianSerils,JieDianName,DangQianUser,ZhuanRuJDSerils,SFKBL,YXBS,ChuangJianRen,ChuangJianSJ,BanLiSJ ");
			strSql.Append(" FROM [ERPXMLB] ");
			strSql.Append(" where ID=@ID ");
			SqlParameter[] parameters = {
					new SqlParameter("@ID", SqlDbType.Int,4)};
			parameters[0].Value = ID;

			DataSet ds=DbHelperSQL.Query(strSql.ToString(),parameters);
			if(ds.Tables[0].Rows.Count>0)
			{
				if(ds.Tables[0].Rows[0]["ID"]!=null && ds.Tables[0].Rows[0]["ID"].ToString()!="")
				{
					this.ID=int.Parse(ds.Tables[0].Rows[0]["ID"].ToString());
				}
				if(ds.Tables[0].Rows[0]["PROJECT_ID"]!=null)
				{
					this.PROJECT_ID=ds.Tables[0].Rows[0]["PROJECT_ID"].ToString();
				}
				if(ds.Tables[0].Rows[0]["PROJECT_NAME"]!=null)
				{
					this.PROJECT_NAME=ds.Tables[0].Rows[0]["PROJECT_NAME"].ToString();
				}
				if(ds.Tables[0].Rows[0]["WorkFlowID"]!=null && ds.Tables[0].Rows[0]["WorkFlowID"].ToString()!="")
				{
					this.WorkFlowID=int.Parse(ds.Tables[0].Rows[0]["WorkFlowID"].ToString());
				}
				if(ds.Tables[0].Rows[0]["WorkFlowName"]!=null)
				{
					this.WorkFlowName=ds.Tables[0].Rows[0]["WorkFlowName"].ToString();
				}
				if(ds.Tables[0].Rows[0]["FormID"]!=null && ds.Tables[0].Rows[0]["FormID"].ToString()!="")
				{
					this.FormID=int.Parse(ds.Tables[0].Rows[0]["FormID"].ToString());
				}
				if(ds.Tables[0].Rows[0]["FormName"]!=null)
				{
					this.FormName=ds.Tables[0].Rows[0]["FormName"].ToString();
				}
				if(ds.Tables[0].Rows[0]["JieDianSerils"]!=null)
				{
					this.JieDianSerils=ds.Tables[0].Rows[0]["JieDianSerils"].ToString();
				}
				if(ds.Tables[0].Rows[0]["JieDianName"]!=null)
				{
					this.JieDianName=ds.Tables[0].Rows[0]["JieDianName"].ToString();
				}
				if(ds.Tables[0].Rows[0]["DangQianUser"]!=null)
				{
					this.DangQianUser=ds.Tables[0].Rows[0]["DangQianUser"].ToString();
				}
				if(ds.Tables[0].Rows[0]["ZhuanRuJDSerils"]!=null)
				{
					this.ZhuanRuJDSerils=ds.Tables[0].Rows[0]["ZhuanRuJDSerils"].ToString();
				}
				if(ds.Tables[0].Rows[0]["SFKBL"]!=null && ds.Tables[0].Rows[0]["SFKBL"].ToString()!="")
				{
					this.SFKBL=int.Parse(ds.Tables[0].Rows[0]["SFKBL"].ToString());
				}
				if(ds.Tables[0].Rows[0]["YXBS"]!=null && ds.Tables[0].Rows[0]["YXBS"].ToString()!="")
				{
					this.YXBS=int.Parse(ds.Tables[0].Rows[0]["YXBS"].ToString());
				}
				if(ds.Tables[0].Rows[0]["ChuangJianRen"]!=null)
				{
					this.ChuangJianRen=ds.Tables[0].Rows[0]["ChuangJianRen"].ToString();
				}
				if(ds.Tables[0].Rows[0]["ChuangJianSJ"]!=null && ds.Tables[0].Rows[0]["ChuangJianSJ"].ToString()!="")
				{
					this.ChuangJianSJ=DateTime.Parse(ds.Tables[0].Rows[0]["ChuangJianSJ"].ToString());
				}
				if(ds.Tables[0].Rows[0]["BanLiSJ"]!=null && ds.Tables[0].Rows[0]["BanLiSJ"].ToString()!="")
				{
					this.BanLiSJ=DateTime.Parse(ds.Tables[0].Rows[0]["BanLiSJ"].ToString());
				}
			}
		}
		/// <summary>
		/// 是否存在该记录
		/// </summary>
		public bool Exists(int ID)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("select count(1) from [ERPXMLB]");
			strSql.Append(" where ID=@ID ");

			SqlParameter[] parameters = {
					new SqlParameter("@ID", SqlDbType.Int,4)};
			parameters[0].Value = ID;

			return DbHelperSQL.Exists(strSql.ToString(),parameters);
		}


		/// <summary>
		/// 增加一条数据
		/// </summary>
		public int Add()
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("insert into [ERPXMLB] (");
			strSql.Append("PROJECT_ID,PROJECT_NAME,WorkFlowID,WorkFlowName,FormID,FormName,JieDianSerils,JieDianName,DangQianUser,ZhuanRuJDSerils,SFKBL,YXBS,ChuangJianRen,ChuangJianSJ,BanLiSJ)");
			strSql.Append(" values (");
			strSql.Append("@PROJECT_ID,@PROJECT_NAME,@WorkFlowID,@WorkFlowName,@FormID,@FormName,@JieDianSerils,@JieDianName,@DangQianUser,@ZhuanRuJDSerils,@SFKBL,@YXBS,@ChuangJianRen,@ChuangJianSJ,@BanLiSJ)");
			strSql.Append(";select @@IDENTITY");
			SqlParameter[] parameters = {
					new SqlParameter("@PROJECT_ID", SqlDbType.NVarChar,50),
					new SqlParameter("@PROJECT_NAME", SqlDbType.NVarChar,200),
					new SqlParameter("@WorkFlowID", SqlDbType.Int,4),
					new SqlParameter("@WorkFlowName", SqlDbType.NVarChar,100),
					new SqlParameter("@FormID", SqlDbType.Int,4),
					new SqlParameter("@FormName", SqlDbType.NVarChar,200),
					new SqlParameter("@JieDianSerils", SqlDbType.NVarChar,10),
					new SqlParameter("@JieDianName", SqlDbType.NVarChar,200),
					new SqlParameter("@DangQianUser", SqlDbType.NVarChar,50),
					new SqlParameter("@ZhuanRuJDSerils", SqlDbType.NVarChar,10),
					new SqlParameter("@SFKBL", SqlDbType.Int,4),
					new SqlParameter("@YXBS", SqlDbType.Int,4),
					new SqlParameter("@ChuangJianRen", SqlDbType.NVarChar,50),
					new SqlParameter("@ChuangJianSJ", SqlDbType.DateTime),
					new SqlParameter("@BanLiSJ", SqlDbType.DateTime)};
			parameters[0].Value = PROJECT_ID;
			parameters[1].Value = PROJECT_NAME;
			parameters[2].Value = WorkFlowID;
			parameters[3].Value = WorkFlowName;
			parameters[4].Value = FormID;
			parameters[5].Value = FormName;
			parameters[6].Value = JieDianSerils;
			parameters[7].Value = JieDianName;
			parameters[8].Value = DangQianUser;
			parameters[9].Value = ZhuanRuJDSerils;
			parameters[10].Value = SFKBL;
			parameters[11].Value = YXBS;
			parameters[12].Value = ChuangJianRen;
			parameters[13].Value = ChuangJianSJ;
			parameters[14].Value = BanLiSJ;

			object obj = DbHelperSQL.GetSingle(strSql.ToString(),parameters);
			if (obj == null)
			{
				return 0;
			}
			else
			{
				return Convert.ToInt32(obj);
			}
		}
		/// <summary>
		/// 更新一条数据
		/// </summary>
		public bool Update()
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("update [ERPXMLB] set ");
			strSql.Append("PROJECT_ID=@PROJECT_ID,");
			strSql.Append("PROJECT_NAME=@PROJECT_NAME,");
			strSql.Append("WorkFlowID=@WorkFlowID,");
			strSql.Append("WorkFlowName=@WorkFlowName,");
			strSql.Append("FormID=@FormID,");
			strSql.Append("FormName=@FormName,");
			strSql.Append("JieDianSerils=@JieDianSerils,");
			strSql.Append("JieDianName=@JieDianName,");
			strSql.Append("DangQianUser=@DangQianUser,");
			strSql.Append("ZhuanRuJDSerils=@ZhuanRuJDSerils,");
			strSql.Append("SFKBL=@SFKBL,");
			strSql.Append("YXBS=@YXBS,");
			strSql.Append("ChuangJianRen=@ChuangJianRen,");
			strSql.Append("ChuangJianSJ=@ChuangJianSJ,");
			strSql.Append("BanLiSJ=@BanLiSJ");
			strSql.Append(" where ID=@ID ");
			SqlParameter[] parameters = {
					new SqlParameter("@PROJECT_ID", SqlDbType.NVarChar,50),
					new SqlParameter("@PROJECT_NAME", SqlDbType.NVarChar,200),
					new SqlParameter("@WorkFlowID", SqlDbType.Int,4),
					new SqlParameter("@WorkFlowName", SqlDbType.NVarChar,100),
					new SqlParameter("@FormID", SqlDbType.Int,4),
					new SqlParameter("@FormName", SqlDbType.NVarChar,200),
					new SqlParameter("@JieDianSerils", SqlDbType.NVarChar,10),
					new SqlParameter("@JieDianName", SqlDbType.NVarChar,200),
					new SqlParameter("@DangQianUser", SqlDbType.NVarChar,50),
					new SqlParameter("@ZhuanRuJDSerils", SqlDbType.NVarChar,10),
					new SqlParameter("@SFKBL", SqlDbType.Int,4),
					new SqlParameter("@YXBS", SqlDbType.Int,4),
					new SqlParameter("@ChuangJianRen", SqlDbType.NVarChar,50),
					new SqlParameter("@ChuangJianSJ", SqlDbType.DateTime),
					new SqlParameter("@BanLiSJ", SqlDbType.DateTime),
					new SqlParameter("@ID", SqlDbType.Int,4)};
			parameters[0].Value = PROJECT_ID;
			parameters[1].Value = PROJECT_NAME;
			parameters[2].Value = WorkFlowID;
			parameters[3].Value = WorkFlowName;
			parameters[4].Value = FormID;
			parameters[5].Value = FormName;
			parameters[6].Value = JieDianSerils;
			parameters[7].Value = JieDianName;
			parameters[8].Value = DangQianUser;
			parameters[9].Value = ZhuanRuJDSerils;
			parameters[10].Value = SFKBL;
			parameters[11].Value = YXBS;
			parameters[12].Value = ChuangJianRen;
			parameters[13].Value = ChuangJianSJ;
			parameters[14].Value = BanLiSJ;
			parameters[15].Value = ID;

			int rows=DbHelperSQL.ExecuteSql(strSql.ToString(),parameters);
			if (rows > 0)
			{
				return true;
			}
			else
			{
				return false;
			}
		}

		/// <summary>
		/// 删除一条数据
		/// </summary>
		public bool Delete(int ID)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("delete from [ERPXMLB] ");
			strSql.Append(" where ID=@ID ");
			SqlParameter[] parameters = {
					new SqlParameter("@ID", SqlDbType.Int,4)};
			parameters[0].Value = ID;

			int rows=DbHelperSQL.ExecuteSql(strSql.ToString(),parameters);
			if (rows > 0)
			{
				return true;
			}
			else
			{
				return false;
			}
		}


		/// <summary>
		/// 得到一个对象实体
		/// </summary>
		public void GetModel(int ID)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("select ID,PROJECT_ID,PROJECT_NAME,WorkFlowID,WorkFlowName,FormID,FormName,JieDianSerils,JieDianName,DangQianUser,ZhuanRuJDSerils,SFKBL,YXBS,ChuangJianRen,ChuangJianSJ,BanLiSJ ");
			strSql.Append(" FROM [ERPXMLB] ");
			strSql.Append(" where ID=@ID ");
			SqlParameter[] parameters = {
					new SqlParameter("@ID", SqlDbType.Int,4)};
			parameters[0].Value = ID;

			DataSet ds=DbHelperSQL.Query(strSql.ToString(),parameters);
			if(ds.Tables[0].Rows.Count>0)
			{
				if(ds.Tables[0].Rows[0]["ID"]!=null && ds.Tables[0].Rows[0]["ID"].ToString()!="")
				{
					this.ID=int.Parse(ds.Tables[0].Rows[0]["ID"].ToString());
				}
				if(ds.Tables[0].Rows[0]["PROJECT_ID"]!=null )
				{
					this.PROJECT_ID=ds.Tables[0].Rows[0]["PROJECT_ID"].ToString();
				}
				if(ds.Tables[0].Rows[0]["PROJECT_NAME"]!=null )
				{
					this.PROJECT_NAME=ds.Tables[0].Rows[0]["PROJECT_NAME"].ToString();
				}
				if(ds.Tables[0].Rows[0]["WorkFlowID"]!=null && ds.Tables[0].Rows[0]["WorkFlowID"].ToString()!="")
				{
					this.WorkFlowID=int.Parse(ds.Tables[0].Rows[0]["WorkFlowID"].ToString());
				}
				if(ds.Tables[0].Rows[0]["WorkFlowName"]!=null )
				{
					this.WorkFlowName=ds.Tables[0].Rows[0]["WorkFlowName"].ToString();
				}
				if(ds.Tables[0].Rows[0]["FormID"]!=null && ds.Tables[0].Rows[0]["FormID"].ToString()!="")
				{
					this.FormID=int.Parse(ds.Tables[0].Rows[0]["FormID"].ToString());
				}
				if(ds.Tables[0].Rows[0]["FormName"]!=null )
				{
					this.FormName=ds.Tables[0].Rows[0]["FormName"].ToString();
				}
				if(ds.Tables[0].Rows[0]["JieDianSerils"]!=null )
				{
					this.JieDianSerils=ds.Tables[0].Rows[0]["JieDianSerils"].ToString();
				}
				if(ds.Tables[0].Rows[0]["JieDianName"]!=null )
				{
					this.JieDianName=ds.Tables[0].Rows[0]["JieDianName"].ToString();
				}
				if(ds.Tables[0].Rows[0]["DangQianUser"]!=null )
				{
					this.DangQianUser=ds.Tables[0].Rows[0]["DangQianUser"].ToString();
				}
				if(ds.Tables[0].Rows[0]["ZhuanRuJDSerils"]!=null )
				{
					this.ZhuanRuJDSerils=ds.Tables[0].Rows[0]["ZhuanRuJDSerils"].ToString();
				}
				if(ds.Tables[0].Rows[0]["SFKBL"]!=null && ds.Tables[0].Rows[0]["SFKBL"].ToString()!="")
				{
					this.SFKBL=int.Parse(ds.Tables[0].Rows[0]["SFKBL"].ToString());
				}
				if(ds.Tables[0].Rows[0]["YXBS"]!=null && ds.Tables[0].Rows[0]["YXBS"].ToString()!="")
				{
					this.YXBS=int.Parse(ds.Tables[0].Rows[0]["YXBS"].ToString());
				}
				if(ds.Tables[0].Rows[0]["ChuangJianRen"]!=null )
				{
					this.ChuangJianRen=ds.Tables[0].Rows[0]["ChuangJianRen"].ToString();
				}
				if(ds.Tables[0].Rows[0]["ChuangJianSJ"]!=null && ds.Tables[0].Rows[0]["ChuangJianSJ"].ToString()!="")
				{
					this.ChuangJianSJ=DateTime.Parse(ds.Tables[0].Rows[0]["ChuangJianSJ"].ToString());
				}
				if(ds.Tables[0].Rows[0]["BanLiSJ"]!=null && ds.Tables[0].Rows[0]["BanLiSJ"].ToString()!="")
				{
					this.BanLiSJ=DateTime.Parse(ds.Tables[0].Rows[0]["BanLiSJ"].ToString());
				}
			}
		}

		/// <summary>
		/// 获得数据列表
		/// </summary>
		public DataSet GetList(string strWhere)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("select * ");
			strSql.Append(" FROM [ERPXMLB] ");
			if(strWhere.Trim()!="")
			{
				strSql.Append(" where "+strWhere);
			}
			return DbHelperSQL.Query(strSql.ToString());
		}

		#endregion  Method
	}
}

